# -*- encoding: utf-8 -*-
"""
File Name: redis_keys_util
Description: Utility class for managing Redis keys used in monitoring pipelines.
Author : 'lirui'
date: 11/1/2024
Contact: marjey_lee@163.com
Change Activity:
11/1/2024:
"""


class RedisKeysUtil:
    """
    A utility class for managing Redis keys used in monitoring pipelines.

    Attributes:
        _publisher_keys (list): A list of Redis keys for publishers.
        _current_problems_keys (list): A list of Redis keys for current problems.
    """
    _publisher_keys = [
        'internal_zabbix_channel',
        'external_zabbix_channel',
        'spider_monitor_channel',
        'dedicated_line_monitor_channel',
        'branch_dedicated_line_monitor_channel'
    ]
    _current_problems_keys = [
        'filtered_internal_zabbix_problems',
        'filtered_external_zabbix_problems',
        'filtered_spider_monitor_problems',
        'filtered_dedicated_line_monitor_problems',
        'filtered_branch_dedicated_line_monitor_problems'
    ]
    _original_current_problems_keys = [
        'all_internal_zabbix_problems',
        'all_external_zabbix_problems',
        'all_spider_monitor_problems',
        'all_dedicated_line_monitor_problems',
        'all_branch_dedicated_line_monitor_problems'

    ]
    _publish_keys_mapping = {
        'internal_zabbix_channel': 'filtered_internal_zabbix_problems',
        'external_zabbix_channel': 'filtered_external_zabbix_problems',
        'spider_monitor_channel': 'filtered_spider_monitor_problems',
        'dedicated_line_monitor_channel': 'filtered_dedicated_line_monitor_problems',
        'branch_dedicated_line_monitor_channel': 'filtered_branch_dedicated_line_monitor_problems'
    }

    _all_keys_mapping = {
        'internal_zabbix_channel': 'all_internal_zabbix_problems',
        'external_zabbix_channel': 'all_external_zabbix_problems',
        'spider_monitor_channel': 'all_spider_monitor_problems',
        'dedicated_line_monitor_channel': 'all_dedicated_line_monitor_problems',
        'branch_dedicated_line_monitor_channel': 'all_branch_dedicated_line_monitor_problems'
    }

    @staticmethod
    def get_all_publisher_keys():
        return RedisKeysUtil._publisher_keys

    @staticmethod
    def get_current_problem_key_by_publisher(publisher_key):
        """
        Gets the Redis key for current problems by publisher.

        Args:
            publisher_key (str): The Redis key for publisher.

        Returns:
            str: The Redis key for current problems.
        """
        return RedisKeysUtil._publish_keys_mapping[publisher_key]

    @staticmethod
    def get_all_problem_key_by_publisher(publisher_key):
        """
        Gets the Redis key for all problems by publisher.

        Args:
            publisher_key (str): The Redis key for publisher.

        Returns:
            str: The Redis key for all problems.
        """
        return RedisKeysUtil._all_keys_mapping[publisher_key]

    @staticmethod
    def get_publisher_keys():
        """
        Gets the Redis keys for publishers.

        Returns:
            list: A list of Redis keys for publishers.
        """
        return RedisKeysUtil._publisher_keys

    @classmethod
    def get_internal_zabbix_publisher_keys(cls):
        """
        Gets the Redis key for internal Zabbix publisher.

        Returns:
            str: The Redis key for internal Zabbix publisher.
        """
        return cls._publisher_keys[0]

    @classmethod
    def get_external_zabbix_publisher_keys(cls):
        """
        Gets the Redis key for external Zabbix publisher.

        Returns:
            str: The Redis key for external Zabbix publisher.
        """
        return cls._publisher_keys[1]

    @classmethod
    def get_spider_monitor_publisher_keys(cls):
        """
        Gets the Redis key for spider monitor publisher.

        Returns:
            str: The Redis key for spider monitor publisher.
        """
        return cls._publisher_keys[2]

    @classmethod
    def get_dedicated_line_monitor_publisher_keys(cls):
        """
        Gets the Redis key for dedicated line monitor publisher.

        Returns:
            str: The Redis key for dedicated line monitor publisher.
        """
        return cls._publisher_keys[3]

    @classmethod
    def get_branch_dedicated_line_monitor_publisher_keys(cls):
        """
        Gets the Redis key for branch dedicated line monitor publisher.

        Returns:
            str: The Redis key for branch dedicated line monitor publisher.
        """
        return cls._publisher_keys[4]

    @classmethod
    def get_internal_zabbix_current_problems_keys(cls):
        """
        Gets the Redis key for internal Zabbix current problems.

        Returns:
            str: The Redis key for internal Zabbix current problems.
        """
        return cls._current_problems_keys[0]

    @classmethod
    def get_external_zabbix_current_problems_keys(cls):
        """
        Gets the Redis key for external Zabbix current problems.

        Returns:
            str: The Redis key for external Zabbix current problems.
        """
        return cls._current_problems_keys[1]

    @classmethod
    def get_spider_monitor_current_problems_keys(cls):
        """
        Gets the Redis key for spider monitor current problems.

        Returns:
            str: The Redis key for spider monitor current problems.
        """
        return cls._current_problems_keys[2]

    @classmethod
    def get_dedicated_line_monitor_current_problems_keys(cls):
        """
        Gets the Redis key for dedicated line monitor current problems.

        Returns:
            str: The Redis key for dedicated line monitor current problems.
        """
        return cls._current_problems_keys[3]

    @classmethod
    def get_branch_dedicated_line_monitor_current_problems_keys(cls):
        """
        Gets the Redis key for branch dedicated line monitor current problems.

        Returns:
            str: The Redis key for branch dedicated line monitor current problems.
        """
        return cls._current_problems_keys[4]
